exports.__esModule = true;
exports.default = undefined;
var def_tt_analytics = function () {
  var e = false;
  var t = false;
  var a = "";
  var n = "";
  function i(e, a, n, i) {
    var s = new XMLHttpRequest();
    var o = "";
    if (a) {
      o = "?";
      for (var l in a) {
        "?" != o && (o += "&");
        o += l + "=" + window.encodeURIComponent(a[l]);
      }
    }
    var r = i + "/" + e + o;
    t && console.log("RequestUrl: " + r);
    s.open("GET", r, true);
    s.onreadystatechange = function () {
      if (4 === s.readyState) {
        if (200 === s.status) {
          var e = JSON.parse(s.responseText);
          null !== n && n(e);
        } else {
          console.error("httpGet status -->", s.status);
        }
      }
    };
    s.send();
  }
  return {
    init(t, s, o, l, r, c) {
      undefined === t && (t = "");
      undefined === s && (s = "");
      undefined === o && (o = "");
      undefined === l && (l = "");
      undefined === r && (r = function r() {});
      undefined === c && (c = function c() {});
      if ("" != t) {
        if ("" != s) {
          i("getZjOpenId", {
            code: t,
            game: s,
            clickid: o,
            promotionid: l
          }, function (t) {
            if (0 == t.code) {
              e = true;
              a = t.openid;
              n = t.session_key;
              r(t);
            } else {
              c(t);
            }
          }, "https://dyzt.jinkezhexin.top:8001");
        } else {
          console.error("参数game错误");
        }
      } else {
        console.error("参数code错误");
      }
    },
    register(t, n) {
      undefined === t && (t = function t() {});
      undefined === n && (n = function n() {});
      if (0 != e) {
        i("zjRegister", {
          openid: a
        }, function (e) {
          if (0 == e.code) {
            t(e);
          } else {
            n(e);
          }
        }, "https://dyzt.jinkezhexin.top:8001");
      } else {
        console.error("sdk未初始化");
      }
    },
    game_addiction(t, n) {
      undefined === t && (t = function t() {});
      undefined === n && (n = function n() {});
      if (0 != e) {
        i("adkanwan", {
          openid: a
        }, function (e) {
          if (0 == e.code) {
            t(e);
          } else {
            n(e);
          }
        }, "https://dyzt.jinkezhexin.top:8001");
      } else {
        console.error("sdk未初始化");
      }
    },
    analytics(t, n, s) {
      undefined === t && (t = "");
      undefined === n && (n = function n() {});
      undefined === s && (s = function s() {});
      if (0 != e) {
        if ("" != t) {
          i("adZhiTou", {
            openid: a,
            eventType: t
          }, function (e) {
            if (0 == e.code) {
              n(e);
            } else {
              s(e);
            }
          }, "https://dyzt.jinkezhexin.top:8001");
        } else {
          console.error("参数eventType错误");
        }
      } else {
        console.error("sdk未初始化");
      }
    },
    analytics_properties(t, n, s, o) {
      undefined === t && (t = "");
      undefined === n && (n = null);
      undefined === s && (s = function s() {});
      undefined === o && (o = function o() {});
      if (0 != e) {
        if ("" != t) {
          if (null != n) {
            i("adZhiTou", {
              openid: a,
              eventType: t,
              properties: JSON.stringify(n)
            }, function (e) {
              if (0 == e.code) {
                s(e);
              } else {
                o(e);
              }
            }, "https://dyzt.jinkezhexin.top:8001");
          } else {
            console.error("参数properties错误");
          }
        } else {
          console.error("参数eventType错误");
        }
      } else {
        console.error("sdk未初始化");
      }
    },
    addGold(t, s, o, l, r, c) {
      undefined === t && (t = 0);
      undefined === s && (s = "");
      undefined === o && (o = 0);
      undefined === l && (l = "");
      undefined === r && (r = function r() {});
      undefined === c && (c = function c() {});
      if (0 != e) {
        if (t <= 0) {
          console.error("amount必须大于0");
        } else if ("" != s) {
          if (0 != o) {
            if ("" != l) {
              if ("" != n) {
                i("lingquJinBi", {
                  openid: a,
                  amount: t,
                  description: s,
                  task_id: o,
                  task_key: l,
                  sessionKey: n
                }, function (e) {
                  if (0 == e.errcode) {
                    r(e);
                  } else {
                    c(e);
                  }
                }, "https://dyzt.jinkezhexin.top:8001");
              } else {
                console.error("参数sessionKey错误");
              }
            } else {
              console.error("参数task_key错误");
            }
          } else {
            console.error("参数task_id错误");
          }
        } else {
          console.error("参数description不能为空字符串");
        }
      } else {
        console.error("sdk未初始化");
      }
    },
    queryGold(t, n) {
      undefined === t && (t = function t() {});
      undefined === n && (n = function n() {});
      if (0 != e) {
        i("searchGold", {
          openid: a
        }, function (e) {
          if (0 == e.errcode) {
            t(e);
          } else {
            n(e);
          }
        }, "https://dyzt.jinkezhexin.top:8001");
      } else {
        console.error("sdk未初始化");
      }
    },
    maxGold(t, n) {
      undefined === t && (t = function t() {});
      undefined === n && (n = function n() {});
      if (0 != e) {
        i("getJinBiShouYi", {
          openid: a
        }, function (e) {
          if (0 == e.code) {
            t(e);
          } else {
            n(e);
          }
        }, "https://dyzt.jinkezhexin.top:8001");
      } else {
        console.error("sdk未初始化");
      }
    },
    debug(e) {
      t = e;
    },
    gametdd(e, t, a, n) {
      undefined === e && (e = "");
      undefined === t && (t = "");
      undefined === a && (a = function a() {});
      undefined === n && (n = function n() {});
      if ("" != e) {
        i("gametdd", {
          id: e,
          sid: t
        }, function (e) {
          if (0 == e.code) {
            a(e.data);
          } else {
            n(e);
          }
        }, "https://dyzt.jinkezhexin.top:8001");
      } else {
        console.error("参数id错误");
      }
    }
  };
}();
exports.default = def_tt_analytics;
module.exports = exports.default;